package com.sskj.tibi.presenter;

import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.CallBackOption;
import com.sskj.tibi.bean.WithdrawBalanceBean;
import com.sskj.tibi.http.HttpConfig;
import com.sskj.tibi.ui.activity.WithdrawActivity;


public class WithdrawActivityPresenter extends BasePresenter<WithdrawActivity> {

    public void getBalance() {
        httpService.getBalance()
                .execute(new CallBackOption<HttpData<WithdrawBalanceBean>>() {
                }.unLoadBind(mView).execute(httpData -> mView.updateUI(httpData.getData())));
    }


    public void withdraw(String address, String money, String payment_password, String code,String stockCode, String googleCode) {
        httpService.withdraw(address, money, payment_password, code,stockCode, googleCode)
                .execute(new CallBackOption<HttpData>() {
                }
                        .loadBind(mView)
                        .execute(httpData -> {
                            ToastUtil.showShort(httpData.getMsg());
                            if (httpData.getStatus() == HttpConfig.OK) {
                                mView.withdrawSuccess();
                            }
                        }));
    }
}
